#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>

using std::cout;
using std::endl;
using std::istream_iterator;
using std::ostream_iterator;
using std::copy;
using std::vector;

class Point
{
public:
    Point()
    {
        cout << "Point()" << endl;
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }
};
void test00()
{
    //显示调用构造函数会创建对象，该对象是临时对象
    //临时对象的生命周期只在本行
    Point();//显示调用无参构造函数
    cout << "1111" << endl;
    Point pt;
    /* pt.Point();//error */
    pt.~Point();
    cout << "2222" << endl;
}

void test()
{
    vector<int> vec;
    /* vec.reserve(20); */
    /* cout << "111" << endl; */
    istream_iterator<int> isi(std::cin);
    cout << "222" << endl;
    /* copy(isi, istream_iterator<int>(), vec.end()); */
    //back_inserter函数的底层会调用push_back
    copy(isi, istream_iterator<int>(), std::back_inserter(vec));
    /* cout << "333" << endl; */
    cout << "vec.size() = " << vec.size() << endl;
    copy(vec.begin(), vec.end(), 
         ostream_iterator<int>(cout, "  "));
    /* cout << "444" << endl; */
    cout << endl;
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

